{template "header.html"}


{php echo \Phpcmf\Service::L('Field')->get('select')->get_select_search_code();}
<div class="right-card-box">
    <div id="toolbar" class="toolbar">
    <div class="row table-search-tool">
        <form action="{SELF}" method="get">
            {dr_form_search_hidden()}
            {if $status}
            <div class="col-md-12 col-sm-12">
                <label>
                    <select name="status[]" class="form-control bs-select" data-title="{dr_lang('账号状态')}" multiple="multiple">
                        {loop $status $i $t}
                        <option value="{$i}" {if dr_in_array($i, $param.status)}selected{/if}>{dr_lang($t)}</option>
                        {/loop}
                    </select>
                </label>
            </div>
            {/if}
            <div class="col-md-12 col-sm-12">
                <label style="min-width: 200px;">
                    <select name="groupid[]" class="form-control bs-select" multiple="multiple" data-title="{dr_lang('用户组')}" data-actions-box="true">
                        {loop $group $t}
                        <option value="{$t.id}" {if dr_in_array($t.id, $param.groupid)}selected{/if}>{dr_lang($t.name)}</option>
                        {/loop}
                    </select>
                </label>
            </div>
            <div class="col-md-12 col-sm-12">
                <label>
                    <select name="field" class="form-control">
                        <option value="id"> Id </option>
                        {loop $field $t}
                        {if dr_is_admin_search_field($t)}
                        <option value="{$t.fieldname}" {if $param.field==$t.fieldname}selected{/if}>{dr_lang($t.name)}</option>
                        {/if}
                        {/loop}
                    </select>
                </label>
                <label><i class="fa fa-caret-right"></i></label>
                <label><input type="text" class="form-control" placeholder="" value="{$param['keyword']}" name="keyword" /></label>
            </div>


            <div class="col-md-12 col-sm-12">
                <label><button type="submit" class="btn blue btn-sm onloading" name="submit" > <i class="fa fa-search"></i> {dr_lang('搜索')}</button></label>
            </div>
        </form>
    </div>
    </div>

    {template "mytable.html"}

    <script>
        $(function () {
            var up = 0;
            $('.dr_username_phone').each(function () {
                var html = $(this).html();
                if (html.length > 44) {
                    up = 1;
                }
            });
            if (up == 0) {
                $('.dr_username_phone').remove();
            }
        });
        // ajax 批量操作确认
        function dr_ajax_option_user(url, remove) {

            layer.confirm(
                '{dr_lang('全部删除: 会联动删除所属的内容和附件。')}<br>'+
            '{dr_lang('只删除账号: 不会影响该账号的相关数据和附件。')}<br>',
                {
                    icon: 3,
                    shade: 0,
                    area: ['500px', '220px'],
                    title: '{dr_lang('确认删除')}',
                    btn: ['{dr_lang('全部删除')}','{dr_lang('只删除账号')}', lang['esc']]
                }, function(index){
                layer.close(index);
                var loading = layer.load(2, {
                    shade: [0.3,'#fff'], //0.1透明度的白色背景
                    time: 5000
                });
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: url+'&sync=1',
                    data: $("#myform").serialize(),
                    success: function(json) {
                        layer.close(loading);
                        if (json.code) {
                            if (remove) {
                                // 批量移出去
                                var ids = json.data.ids;
                                if (typeof ids != "undefined" ) {
                                    console.log(ids);
                                    for ( var i = 0; i < ids.length; i++){
                                        $("#dr_row_"+ids[i]).remove();
                                    }
                                }
                            }
                            if (json.data.htmlfile) {
                                // 执行生成htmljs
                                $.ajax({
                                    type: "GET",
                                    url: json.data.htmlfile,
                                    dataType: "jsonp",
                                    success: function(json){ },
                                    error: function(){ }
                                });
                            }
                            if (json.data.url) {
                                setTimeout("window.location.href = '"+json.data.url+"'", 2000);
                            } else {
                                setTimeout("window.location.reload(true)", 3000)
                            }
                        }
                        dr_cmf_tips(json.code, json.msg);
                    },
                    error: function(HttpRequest, ajaxOptions, thrownError) {
                        dr_ajax_alert_error(HttpRequest, this, thrownError);
                    }
                });
            }, function(index){
                layer.close(index);
                var loading = layer.load(2, {
                    shade: [0.3,'#fff'], //0.1透明度的白色背景
                    time: 5000
                });
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: url+'&sync=0',
                    data: $("#myform").serialize(),
                    success: function(json) {
                        layer.close(loading);
                        if (json.code) {
                            if (remove) {
                                // 批量移出去
                                var ids = json.data.ids;
                                if (typeof ids != "undefined" ) {
                                    console.log(ids);
                                    for ( var i = 0; i < ids.length; i++){
                                        $("#dr_row_"+ids[i]).remove();
                                    }
                                }
                            }
                            if (json.data.htmlfile) {
                                // 执行生成htmljs
                                $.ajax({
                                    type: "GET",
                                    url: json.data.htmlfile,
                                    dataType: "jsonp",
                                    success: function(json){ },
                                    error: function(){ }
                                });
                            }
                            if (json.data.url) {
                                setTimeout("window.location.href = '"+json.data.url+"'", 2000);
                            } else {
                                setTimeout("window.location.reload(true)", 3000)
                            }
                        }
                        dr_cmf_tips(json.code, json.msg);
                    },
                    error: function(HttpRequest, ajaxOptions, thrownError) {
                        dr_ajax_alert_error(HttpRequest, this, thrownError);
                    }
                });

            });
        }
    </script>
</div>

{template "footer.html"}